﻿using Proxy;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using HomagGroup.Base.UI.Controls;

namespace Proxy
{
    public class CanvasExample : UseGraphHooks
    {
        /// <summary>
        /// 画布容器
        /// </summary>
        public override Canvas Element { get; set; }
        /// <summary>
        /// 动画时长
        /// </summary>
        public override TimeSpan AnimationSeconds { get; set; } = TimeSpan.FromSeconds(0.5);
        /// <summary>
        /// 出入库背景图Key
        /// </summary>
        public override string ImageKey { get; set; } = "OutOrIn";
        /// <summary>
        /// 库位颜色
        /// </summary>
        public override string StorageColor { get; set; } = "#7493B8";

        private SearchInfoHandle Handle_Search = new SearchInfoHandle();

        public override ObservableCollection<StorageSpaceModel> StorageSpaceList { get; set; }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="element"></param>
        /// <param name="storageSpaceList"></param>
        public CanvasExample(Canvas element, ObservableCollection<StorageSpaceModel> storageSpaceList)
        {
            this.Element = element;
            this.StorageSpaceList = storageSpaceList;
            element.Loaded += (s, e) => CreateStorageView();
        }

        /// <summary>
        /// 刷新进度条
        /// </summary>
        public override void OnRefreshProgress()
        {
            foreach (BulletGraph bulletGraph in bulletGraphsList)
            {
                bulletGraph.Value = Handle_Search.GetUsage(bulletGraph.Uid);
            }
        }
    }
}